/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package viewControl;

import org.hibernate.Session;

/**
 *
 * @author Morten Bormeth
 */
public class TherapistGUI extends javax.swing.JFrame {

    private Session session;
    private boolean rdy;
    private ElevPanel ep;
    private KontaktPanel kp;
    private ElevLogPanel elp;

    /**
     * Creates new form TherepistGUI
     */
    public TherapistGUI(Session session) {
        this.session = session;
        rdy = false;
        initComponents();

        //Indsæt ElevPanel
        ep = new ElevPanel(session);
        elevPanel.add(ep);
        elevPanel.validate();
        ep.update();
        ep.setBounds(0, 0, elevPanel.getWidth(), elevPanel.getHeight());
        ep.limitPanel();

        //Indsæt KontaktPanel
        kp = new KontaktPanel(session);
        kontaktpersonPanel.add(kp);
        kontaktpersonPanel.validate();
        kp.update();
        kp.setBounds(0, 0, kontaktpersonPanel.getWidth(), kontaktpersonPanel.getHeight());
        kp.limitPanel();

        //Indsæt ElevLogPanel
        elp = new ElevLogPanel(session);
        elevLogPanel.add(elp);
        elevLogPanel.validate();
        elp.update();
        elp.setBounds(0, 0, elevLogPanel.getWidth(), elevLogPanel.getHeight());
        setLocationRelativeTo(null);
        rdy = true;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tpRapist = new javax.swing.JTabbedPane();
        elevPanel = new javax.swing.JPanel();
        elevLogPanel = new javax.swing.JPanel();
        kontaktpersonPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Logget ind som Pædago");

        tpRapist.setPreferredSize(new java.awt.Dimension(986, 741));
        tpRapist.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tpRapistStateChanged(evt);
            }
        });

        elevPanel.setLayout(null);
        tpRapist.addTab("Elev", elevPanel);

        elevLogPanel.setLayout(null);
        tpRapist.addTab("Elev log", elevLogPanel);

        kontaktpersonPanel.setLayout(null);
        tpRapist.addTab("Kontaktperson", kontaktpersonPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tpRapist, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tpRapist, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tpRapistStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tpRapistStateChanged
        // TODO add your handling code here:
        if (rdy) {
            //ep.update();
            kp.update();
            elp.update();
        }
    }//GEN-LAST:event_tpRapistStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel elevLogPanel;
    private javax.swing.JPanel elevPanel;
    private javax.swing.JPanel kontaktpersonPanel;
    private javax.swing.JTabbedPane tpRapist;
    // End of variables declaration//GEN-END:variables
}
